#ifndef sheet_entry_impl_h
#define sheet_entry_impl_h

#include "../include/sheet.h"

#include <vector>

class sheet_impl;
class cell_impl;

class cell_iterator_impl : public excel::cell_iterator
{
	typedef std::vector<excel::cell*>::iterator c_iter;
public:
	cell_iterator_impl(c_iter cur, c_iter end);

	cell_iterator_impl(c_iter end);
	
	virtual bool next();

	inline virtual excel::cell* get_cell()	{ return *(m_iter_cur); }

	virtual bool is_equal(const cell_iterator* rhs);

	inline virtual cmn::dword release()
	{
		delete this;
		return 0;
	}

private:
	c_iter m_iter_cur;
	c_iter m_iter_end;
};

class entry_impl : public excel::entry
{
public:
	entry_impl(sheet_impl* sheet, cmn::kcwstr memdata, int size);

	~entry_impl();

	virtual excel::cell*	get_cell(int column);

	virtual excel::cell*	get_cell(kcwstr title);

	virtual excel::cell*	get_id_cell();

	virtual excel::sheet*	get_sheet();

	virtual int		get_id();

	virtual excel::cell_iterator*	first()	{ return new cell_iterator_impl(m_cells.begin(), m_cells.end()); }

	virtual excel::cell_iterator*	last()	{ return new cell_iterator_impl(m_cells.end()); }

	int	get_column(cell_impl* cell);

	inline bool is_loaded()					{ return m_is_loaded; }

	inline virtual cmn::dword release()
	{
		delete this;
		return 0;
	}

private:
	bool parse_entry_data(cmn::kcwstr memdata, int size);

	bool parse_entry_cell(int column, cmn::kcwstr memdata, int size);
	
	sheet_impl*	m_sheet;
	bool		m_is_loaded;

	std::vector<excel::cell*> m_cells;
};

#endif	//sheet_entry_impl_h

